package com.example.pestcontrol.admin;

import org.kymjs.kjframe.KJActivity;
import org.kymjs.kjframe.ui.BindView;

import android.view.View;
import android.widget.TextView;

import com.example.pestcontrol.R;

public class AdminViewUserActivity extends KJActivity {

	AdminViewGeneralUserFragment generalfragment;
	AdminViewExpertsUserFragment expertsfragemnt;

	@BindView(id = R.id.general_user, click = true)
	private TextView general_user;

	@BindView(id = R.id.experts_user, click = true)
	private TextView experts_user;

	@Override
	public void setRootView() {
		setContentView(R.layout.user_info_activity);
	}

	@Override
	public void initData() {
		super.initData();
	}

	@Override
	public void initWidget() {

		if (generalfragment == null) {
			generalfragment = new AdminViewGeneralUserFragment();
		}
		changeFragment(R.id.user_info_fragment, generalfragment);
		super.initWidget();
	}

	@Override
	public void widgetClick(View v) {
		switch (v.getId()) {
		case R.id.general_user:
			changewidget(R.id.general_user);
			if (generalfragment == null) {
				generalfragment = new AdminViewGeneralUserFragment();
			}
			changeFragment(R.id.user_info_fragment, generalfragment);
			break;
		case R.id.experts_user:
			changewidget(R.id.experts_user);
			if (expertsfragemnt == null) {
				expertsfragemnt = new AdminViewExpertsUserFragment();
			}
			changeFragment(R.id.user_info_fragment, expertsfragemnt);
			break;

		default:
			break;
		}

		super.widgetClick(v);
	}

	public void changewidget(int id) {
		switch (id) {
		case R.id.general_user:
			general_user.setBackgroundResource(R.color.bottombg);
			experts_user.setBackgroundResource(R.color.white);

			general_user.setTextColor(getResources().getColor(R.color.red));
			experts_user.setTextColor(getResources().getColor(R.color.black));
			break;
		case R.id.experts_user:
			general_user.setBackgroundResource(R.color.white);
			experts_user.setBackgroundResource(R.color.bottombg);

			general_user.setTextColor(getResources().getColor(R.color.black));
			experts_user.setTextColor(getResources().getColor(R.color.red));
			break;
		default:
			break;
		}
	}

}
